package com.offcn;

import java.sql.*;

public class Select {
    public static void main(String[] args) throws ClassNotFoundException, SQLException {
        //加载驱动
        Class.forName("com.mysql.jdbc.Driver");
        //创建连接
        Connection conn = DriverManager.getConnection("jdbc:mysql://127.0.0.1:3306/myschool", "root", "root");
        //创建sql执行平台
        Statement stmt = conn.createStatement();
        //执行sql语句
        String sql = "select *from emp";
        ResultSet  rs = stmt.executeQuery(sql);
        while (rs.next()) {
            System.out.println(rs.getInt(1) + "\t" + rs.getString(2)+"\t"+rs.getString(3)+"\t"+rs.getInt(4)+"\t"+rs.getString(5)+"\t"+rs.getInt(6)+"\t"+rs.getInt(7)+"\t"+rs.getInt(8));
        }
        rs.close();
        conn.close();
        stmt.close();
    }



}
